<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 对象的解构赋值：

        const  ob = {name:"张三", sex:"男", age:20};
        // 使用解构赋值将上面对象中的属性解析出来
        // let {name, sex, age}  = ob;
        // console.log(name, age, sex);

        // // 可以不分先后顺序和个数（解构部分属性值）
        // let {age, sex} = ob;
        // console.log(age, sex);

        // // 还可以起别名,如下，解构name和 age属性，并起别名：n和a
        // let {name:n,age:a} = ob;
        // console.log(n, a);


        //复杂解构
        const wangfei = {
            name: '王菲',
            age: 18,
            songs: ['红豆', '流年', '暧昧', '传奇'],
            history: [
                {name: '窦唯'},
                {name: '李亚鹏'},
                {name: '谢霆锋'}
            ]
        };

        let {name, songs,} = wangfei;
        console.log(name);

        console.log(songs);

        // 解构出 “流年” 歌名
        let  {songs:[,b]}  = wangfei;
        console.log(b);

        // 解构出 “李亚鹏” 名字
        let {history:[,{name:m}]} = wangfei;
        console.log(m);
    </script>
</body>
</html>